<?php
/**
* sharerecord.php
*
* Create on 2015-4-22
* Create by TT
*/
namespace haibao\cms\business;

use haibao\cms\data\ShareRecord as ShareRecordData;

class ShareRecord extends Base{
	/**
	 * 添加分享记录
	 * @param : object \haibao\cms\model\data\ShareRecord
	 */
	
	public static function addShareRecord($shareRecordModel){
		
		if(!isset($shareRecordModel->InfoId) || $shareRecordModel->InfoId < 0){
			throw new \haibao\www\business\BusinessException('数据错误',self::DATA_ERROR);
		}
		
		switch ($shareRecordModel->InfoType){
			case \haibao\cms\model\data\ShareRecord::INFO_TYPE_ARTICLE:
				$shareRecordData = new ShareRecordData();
				$shareRecordData->add($shareRecordModel);
				$articleData = new \haibao\cms\data\Article();
				$articleData->updateArticleShareNum($shareRecordModel->InfoId);
				break;
			case \haibao\cms\model\data\ShareRecord::INFO_TYPE_IMAGE:
				$shareRecordData = new ShareRecordData();
				$shareRecordData->add($shareRecordModel);
				$collData = new \haibao\cms\data\imagecollective\ImageCollective();
				$collData->updateImageCollectiveShareNum($shareRecordModel->InfoId);
				break;
			case \haibao\cms\model\data\ShareRecord::INFO_TYPE_VIDEO:
				$shareRecordData = new ShareRecordData();
				$shareRecordData->add($shareRecordModel);
				$videoData = new \haibao\cms\data\Video();
				$videoData->updateVideoShareNum($shareRecordModel->InfoId);
				break;
			case \haibao\cms\model\data\ShareRecord::INFO_TYPE_APP_ARTICLE:
				$articleData = new \haibao\app\data\Article();
				$articleData->addShare($shareRecordModel->InfoId,$shareRecordModel->ShareType,$shareRecordModel->Uid);
				break;
			case \haibao\cms\model\data\ShareRecord::INFO_TYPE_BLOG_ARTICLE:
				$shareRecordData = new ShareRecordData();
				$shareRecordData->add($shareRecordModel);
				break;
		}
		
	}
}